//
// Created by Gorun on 2022/5/3.
//

#ifndef LOXPP_NATIVEFUNCTIONS_H
#define LOXPP_NATIVEFUNCTIONS_H

#include <any>
#include <chrono>
#include <iostream>
#include <string>
#include <string_view>

#include "LoxFunction.h"

using namespace std;

class NativeClock: public LoxFunction {
public:
    NativeClock()
    : LoxFunction(nullptr, nullptr, true, false)
    {}

    int arity() override {
        return 0;
    }
    any call(Interpreter& interpreter, vector<any> arguments) override {
        auto ticks = chrono::system_clock::now().time_since_epoch();
        return chrono::duration<double>{ticks}.count() / 1000.0;
    }
};

#endif //LOXPP_NATIVEFUNCTIONS_H
